package com.ruoyi.gift.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.gift.domain.StaRoad;
import com.ruoyi.gift.service.IStaRoadService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;


import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 按照道路名称统计记录；statistics_roadController
 *
 * @author luoShuang
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/system/road")
public class StaRoadController extends BaseController
{
    @Autowired
    private IStaRoadService staRoadService;

    /**
     * 查询按照道路名称统计记录；statistics_road列表
     */
    @PreAuthorize("@ss.hasPermi('system:road:list')")
    @GetMapping("/list")
    public TableDataInfo list(StaRoad staRoad)
    {
        startPage();
        List<StaRoad> list = staRoadService.selectStaRoadList(staRoad);
        return getDataTable(list);
    }

    /**
     * 导出按照道路名称统计记录；statistics_road列表
     */
    @PreAuthorize("@ss.hasPermi('system:road:export')")
    @Log(title = "按照道路名称统计记录；statistics_road", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StaRoad staRoad)
    {
        List<StaRoad> list = staRoadService.selectStaRoadList(staRoad);
        ExcelUtil<StaRoad> util = new ExcelUtil<StaRoad>(StaRoad.class);
        util.exportExcel(response, list, "按照道路名称统计记录；statistics_road数据");
    }

    /**
     * 获取按照道路名称统计记录；statistics_road详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:road:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(staRoadService.selectStaRoadById(id));
    }

    /**
     * 新增按照道路名称统计记录；statistics_road
     */
    @PreAuthorize("@ss.hasPermi('system:road:add')")
    @Log(title = "按照道路名称统计记录；statistics_road", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StaRoad staRoad)
    {
        return toAjax(staRoadService.insertStaRoad(staRoad));
    }

    /**
     * 修改按照道路名称统计记录；statistics_road
     */
    @PreAuthorize("@ss.hasPermi('system:road:edit')")
    @Log(title = "按照道路名称统计记录；statistics_road", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StaRoad staRoad)
    {
        return toAjax(staRoadService.updateStaRoad(staRoad));
    }

    /**
     * 删除按照道路名称统计记录；statistics_road
     */
    @PreAuthorize("@ss.hasPermi('system:road:remove')")
    @Log(title = "按照道路名称统计记录；statistics_road", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(staRoadService.deleteStaRoadByIds(ids));
    }
}